<template>
  <div class="container">
    <van-nav-bar title="下单记录" left-text="返回" right-text left-arrow @click-left="onClickLeft" fixed/>
    <div class="card" @click="toRecordDetail(item.id)" v-for="(item,index) in initData.list" :key="index">
      <div class="row1">
        <div class="left">{{item.add_date}}</div>
        <div class="right">已查阅</div>
      </div>
      <div class="row2">
        <div class="left">材料下单统计：共{{item.OrderDetailedSize}}项</div>
        <div class="right">￥{{item.OrderDetailedCash}}</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "orderRecord",
  data() {
    return {
      initData: []
    };
  },
  mounted() {
    this.getInitData();
  },
  methods: {
    onClickLeft() {
      this.$router.back();
    },
    toRecordDetail(id) {
      this.$router.push({ path: "/recordDetail", query: {
        order_id:id
      } });
    },  
    async getInitData() {
       let params = {
        user_id: this.$cookies.get("user_id"),
        // user_id: 1,
      };
      const res = await this.$axios.post(this.$api.order_list, params);
      if (res.code == 1) {
       this.initData=res.data;
      } else {
        this.$toast(res.msg);
      }
    }
  }
};
</script>
<style scoped>
.container {
  padding: 0.46rem 0.15rem 0;
}
.card {
  background: #fff;
  padding: 0.15rem;
  margin-top: 0.1rem;
  border-radius: 0.05rem;
  color: #999999;
}
.card > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card .row1 {
  margin-bottom: 0.05rem;
}
</style>


